-
-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSON-RPC capability #1373
Add JSON-RPC capability #1373
Conversation
This should probably add options to enable/disable xmlrpc or json handling. |
40f771e
to
e248216
Compare
Were you thinking compile flag options or command options, and can you expand on the use case for this? They should be able to coexist peacefully, if a client doesn't want to use one or the other all they have to do is not send that type of request. |
One example is the flood users, who knows where else this might cause issues. This allows users/providers force the use of a particular protocol for performance or compatibility reasons. It should be command value to enable/disable each. |
Added a toggle for each, and renamed some of the commands/variables from |
78c321e
to
2019c03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy
found issue(s) with the introduced code (1/1)
bool process(RPCType type, const char* in_buffer, uint32_t length, slot_response_callback callback); | ||
|
||
void insert_command(const char* name, const char* parm, const char* doc); | ||
static void object_to_target(const torrent::Object& obj, int callFlags, rpc::target_type* target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid case style for parameter callFlags
static void object_to_target(const torrent::Object& obj, int callFlags, rpc::target_type* target); | |
static void object_to_target(const torrent::Object& obj, int call_flags, rpc::target_type* target); |
Inline nlohmann/json for the JSON parsing itself, and handle requests with the same SCGI interface as XML-RPC. Based off the work in https://github.com/jesec/rtorrent
2019c03
to
8d3cb10
Compare
really glad to see this feature is finally implemented on upstream |
Based off the work in https://github.com/jesec/rtorrent, this implements the 2.0 specification: https://www.jsonrpc.org/specification. It adds a new RpcManager class and a little SCGI logic to handle switching between XML and JSON seamlessly. If the
CONTENT_TYPE
header is present and set toapplication/json
(ortext/xml
for XML-RPC), it'll use that, otherwise it will peek at the body to auto-detect it.The main benefit is reduced message size, as seen on this synthetic set of 10k torrents:
One limitation of JSON-RPC is that it doesn't have a dedicated binary data type. Due to that, base64 data URI support has been added to all the
load.*
commands. Those are currently the only commands which normally need to take binary data, but any future commands would have to follow the same pattern or implement their own scheme.Note for Flood users
When Flood detects the presence of JSON-RPC, it assumes that the full jesec/rtorrent capabilities are available, which breaks a couple things. Thankfully, it's pretty easy to provide some stubs/redirects to get it working: